//package com.digiwin.demo.influx;
//
//import com.influxdb.client.InfluxDBClient;
//import com.influxdb.client.InfluxDBClientFactory;
//import com.influxdb.client.domain.*;
//
//import java.util.Arrays;
//
///**
// * @Author yanggld
// * @Date 2020/1/3-9:31
// * @Description
// */
//public class InfluxDB2ManagementExample {
//
//	static String token1 = "7OAfDlRiyGnHOdV9rcSvog78WJilHM1geAw_Z4m9xrVuVl1Nov6HfnZpj1LJUmN8S9k9ej5cY_7dDuAmlYKB3Q==";
//	private static char[] token = token1.toCharArray();
//
//	public static void main(final String[] args) {
//
//		InfluxDBClient influxDBClient = InfluxDBClientFactory.create("http://172.16.1.198:9999", token);
//
//		//
//		// Create bucket "iot_bucket" with data retention set to 3,600 seconds
//		//
//		BucketRetentionRules retention = new BucketRetentionRules();
//		retention.setEverySeconds(3600);
//
//		Bucket bucket = influxDBClient.getBucketsApi().createBucket("mytest", retention, "f289e8d31184b72b");
//
//		//
//		// Create access token to "iot_bucket"
//		//
//		PermissionResource resource = new PermissionResource();
//		resource.setId(bucket.getId());
//		resource.setOrgID("f289e8d31184b72b");
//		resource.setType(PermissionResource.TypeEnum.BUCKETS);
//
//		// Read permission
//		Permission read = new Permission();
//		read.setResource(resource);
//		read.setAction(Permission.ActionEnum.READ);
//
//		// Write permission
//		Permission write = new Permission();
//		write.setResource(resource);
//		write.setAction(Permission.ActionEnum.WRITE);
//
//		Authorization authorization = influxDBClient.getAuthorizationsApi()
//				.createAuthorization("f289e8d31184b72b", Arrays.asList(read, write));
//
//		//
//		// Created token that can be use for writes to "iot_bucket"
//		//
//		String token = authorization.getToken();
//		System.out.println("Token: " + token);
//
//		influxDBClient.close();
//	}
//}